home *** CD-ROM | disk | FTP | other *** search
- (*********************************************************************
- *
- * PROGRAM NAME: PLAYVOCD.PAS
- *
- * COMPILER: Borland Turbo Pascal ver. 4 or later
- *
- * DESCRIPTION: Plays a .VOC file from the disk using the CTVDSK.DRV
- * double buffering driver (accessed from SBSIM). To run
- * the program, type the following at the command line:
- *
- * PLAYVOCD FILENAME
- *
- * Where FILENAME is the drive/path/filename of the .VOC
- * file to play.
- *
- * NOTE: SBSIM driver must be loaded before running this program.
- *
- *********************************************************************)
-
- program playvocd;
- uses dos,crt;
-
- const VOC_DSK_DRIVER = $02;
-
-
- {$I drvrfunc.pas}
-
-
- var Command:char;
- UserQuit:boolean;
- RetValue:simerr;
- FileName:string;
- FileHandle:integer;
-
- (********************************************************************)
- begin (* main *)
-
- if paramcount <> 1 (* no. of parameters entered on command line *)
- then begin
- writeln('Command line must contain EXACTLY ONE filename parameter!');
- halt; (* Terminate program *)
- end;
-
- (*--- SEE IF SBSIM DRIVER HAS LOADED --*)
- SIMint := FindDvr('SBSIM', $0103); (* Get SBSIM's interrupt no. *)
- if SIMint = 0
- then begin
- writeln('SBSIM driver not loaded!');
- halt; (* Terminate program *)
- end;
-
- (*--- SEE IF CTVDSK.DRV DRIVER HAS LOADED -------*)
- if (GetDrvrs and VOC_DSK_DRIVER) <> VOC_DSK_DRIVER
- then begin
- writeln('CTVDSK.DRV not loaded!');
- halt; (* Terminate program *)
- end;
-
-
- (*--- LOAD THE FILE SPECIFIED ON COMMAND LINE (stored in argv[1]) ----*)
- FileHandle := DosOpen(paramstr(1), ReadAccess);
- if (FileHandle = -1)
- then begin
- writeln('FILE: ',paramstr(1), ' not successfully opened!');
- halt; (* Terminate program *)
- end;
-
- DosClose(FileHandle);
-
- FileName:=paramstr(1); (* copy to string with more space before modifying *)
-
- (*--- StartSnd() LOADS THE FILE AND INITIALIZES THE CTVDSKK.DRV DRIVER ---*)
- RetValue := StartSnd(DskVoice, AsciiZ(FileName), false, 0);
- if RetValue <> SIMerr_NoErr
- then begin
- writeln('ERROR CALLING SBSIM: ', errorMsg[RetValue]);
- halt; (* Terminate program *)
- end;
-
- (*--- BEGIN PLAYING OF THE FILE -----------------------------------------*)
- RetValue := PlaySnd(DskVoice);
- if RetValue <> SIMerr_NoErr
- then begin
- writeln('ERROR CALLING SBSIM: ', errorMsg[RetValue]);
- halt; (* Terminate program *)
- end;
-
- clrscr; (* Clear screen *)
- writeln(#10#10#10#10#10' SELECT ONE OF THE FOLLOWING OR WAIT UNTIL DONE:');
- writeln(' (P)ause');
- writeln(' (R)esume');
- writeln(' (Q)uit');
-
- UserQuit := false;
-
- (*--- PROCESS USER INTERACTION OR WAIT FOR SOUND TO STOP -----------*)
- repeat
- if (keypressed) (* Was a key pressed? *)
- then begin
- Command := upcase(readkey); (* Get char that's in buffer *)
- if Command = 'P'
- then PauseSnd(DskVoice)
- else if Command = 'R'
- then ResumeSnd(DskVoice)
- else if Command = 'Q'
- then UserQuit := true;
- end;
- (* Exit do-while loop if file is done playing or user typed 'Q' *)
- until (UserQuit = true) or (GetSndStat(DskVoice) = 0);
-
-
- (*--- IF SOUND IS STILL PLAYING AND USER HIT 'Q', STOP THE SOUND ---*)
- if (GetSndStat(DskVoice) <> 0) and (UserQuit = true)
- then StopSnd(DskVoice);
-
- end.
-